//
//  SWPoetriesFetchReq.swift
//  ChildStory
//
//  Created by linhan on 2016/12/9.
//  Copyright © 2016年 Aiya. All rights reserved.
//

import Foundation
class SWPoetriesFetchReq: SWBaseRequest
{
    var categoryID:Int = 0
    var count:Int = 0
    var index:Int = 0
    
    override init()
    {
        super.init()
        api = SWRequestAPI.PoetriesFetch
    }
    
    override var params:Any?
    {
        return ["typeId":categoryID]
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        return Mapper<SWPoetriesFetchRsp>().map(JSONString: JSONString)
    }
}

class SWPoetriesFetchRsp: NSObject,Mappable
{
    var poetries:[SWPoetryRsp]?
    var code:Int?
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        code        <- map["Status"]
        poetries  <- map["BaseModle.list"]
    }
}

class SWPoetryRsp: NSObject,Mappable
{
    var id:Int?
    var name:String?
    var artist:String?
    var category:String?
    var summary:String?
    var contentURL:String?
    var dynasty:String?
    
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        id       <- map["id"]
        name     <- map["title"]
        artist   <- map["artist"]
        category   <- map["category"]
        dynasty   <- map["dynasty"]
        summary   <- map["summary"]
        contentURL   <- map["sourceUrl"]
    }
}

